<template>
    <div class="order-report">
        <div class="report-table-top-title">查看序列号</div>
        <div class="report-table-form1">
            <div class="report-table-form1-line">
                <div
                    class="report-table-form1-item word samll"
                    style="width: 80px; text-align: right"
                >
                    序列号:
                </div>
                <div class="report-table-form1-item" style="width: 220px">
                    <el-input
                        class="items"
                        size="small"
                        placeholder="请输入"
                        v-model="searchParam.dogNo"
                    ></el-input>
                </div>
                <div
                    class="report-table-form1-item word samll"
                    style="width: 80px; text-align: right"
                >
                    sn码:
                </div>
                <div class="report-table-form1-item" style="width: 220px">
                    <el-input
                        class="items"
                        size="small"
                        placeholder="请输入"
                        v-model="searchParam.sn"
                    ></el-input>
                </div>
                <div
                    class="report-table-form1-item word samll"
                    style="width: 80px; text-align: right"
                >
                    绑定的商家:
                </div>
                <div class="report-table-form1-item" style="width: 220px">
                    <el-input
                        class="items"
                        size="small"
                        placeholder="请输入"
                        v-model="searchParam.companyCode"
                    ></el-input>
                </div>
                <div style="margin-top: 20px">
                    <div
                        class="report-table-form1-item word samll"
                        style="width: 80px; text-align: right"
                    >
                        代理商:
                    </div>
                    <div class="report-table-form1-item" style="width: 220px">
                        <el-select
                            class="items"
                            v-model="searchParam.agentId"
                            clearable
                            filterable
                            size="small"
                        >
                            <el-option label="全部" :value="null"></el-option>
                            <el-option
                                v-for="item in agentList"
                                :key="item.id"
                                :label="item.userName"
                                :value="item.id"
                            ></el-option>
                        </el-select>
                    </div>
                    <div
                        class="report-table-form1-item word samll"
                        style="width: 80px; text-align: right"
                    >
                        是否绑定:
                    </div>
                    <div class="report-table-form1-item" style="width: 220px">
                        <el-select
                            class="items"
                            v-model="searchParam.whetherBind"
                            size="small"
                        >
                            <el-option label="全部" :value="null"></el-option>
                            <el-option label="否" :value="0"></el-option>
                            <el-option label="是" :value="1"></el-option>
                        </el-select>
                    </div>
                    <el-button type="primary" size="small" @click="reSearch"
                        >查询</el-button
                    >
                    <el-button
                        type="primary"
                        plain
                        size="small"
                        @click="initParams"
                        >重置</el-button
                    >
                </div>
            </div>
        </div>
        <div class="page-padding-gray-small"></div>
        <div class="report-table-wrapper">
            <el-table
                :header-cell-style="headerCellStyle"
                size="small"
                :data="tabData"
                border
                style="width: 100%"
            >
                <el-table-column
                    prop="agentName"
                    label="代理商"
                    min-width="160"
                    show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                    prop="sn"
                    label="sn码"
                    min-width="160"
                    show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                    prop="dogNo"
                    label="序列号"
                    min-width="160"
                    show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                    prop="whetherBindName"
                    label="是否绑定"
                    min-width="160"
                    show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                    prop="companyCode"
                    label="商家编号"
                    min-width="160"
                    show-overflow-tooltip
                ></el-table-column>
            </el-table>
        </div>
        <!-- 分页 -->
        <div class="report-table-block">
            <div class="report-table-block-in">
                <el-pagination
                    background
                    :current-page.sync="currentPage"
                    @current-change="handleCurrentChange"
                    :page-size="pageSize"
                    layout="prev, pager, next, total"
                    :total="totalNum"
                ></el-pagination>
            </div>
        </div>
    </div>
</template>

<script type="text/ecmascript-6">
export default {
    components: {
    },
    data: function () {
        return {
            agentList: [],
            currRow: {},
            terminalTypeList: [], // 设备类型
            typeList: [], // 升级包类型
            statusList: [], // 状态列表
            row: null,
            loading: false,
            searchParam: {
                agentId: null,
                dogNo: '',
                sn: '',
                whetherBind: null,
                companyCode: ''
            },
            currentPage: 1,
            pageSize: 10,
            totalNum: 0,
            tabData: []
        }
    },
    mounted () {
    },
    created () {
        this.getAllAgent()
        this.getList()
    },
    watch: {
    },
    props: {
        underLine: null
    },
    methods: {
        initParams () {
            this.searchParam.agentId = null
            this.searchParam.dogNo = ''
            this.searchParam.sn = ''
            this.searchParam.whetherBind = null
            this.searchParam.companyCode = ''
            this.currentPage = 1
            this.pageSize = 10
            this.getList()
        },
        upgradeStatusList () {
            this.$http.get(this.$store.state.IP + '/upgradeManage/upgradeStatusList?upgradeStage=2', {
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    this.statusList = response.res
                }
            }, response => {
            })
        },
        handleCurrentChange (page) {
            // 换页
            this.currentPage = page
            this.getList()
        },
        reSearch () {
            this.currentPage = 1
            this.getList()
        },
     getAllAgent () {
            // 获取 所有 代理商列表
            this.$http.post(this.$store.state.IP + '/system/company/getAllAgent', {
                data: {
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    this.agentList = response.data
                }
                if (response.ret !== '0') {
                    console.log('调用获取所有代理商失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },
        getList () {
            // 获取 所有 服务列表
            this.$http.post(this.$store.state.IP + '/dogNoManage/getAdminDogNoPageList', {
                agentId: this.searchParam.agentId,
                dogNo: this.searchParam.dogNo,
                sn: this.searchParam.sn,
                whetherBind: this.searchParam.whetherBind,
                companyCode: this.searchParam.companyCode,
                page: this.currentPage - 1,
                size: this.pageSize
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                response = response.body
                this.tabData = []
                if (response.ret === '0') {
                    this.tabData = response.res.list
                    this.totalNum = response.res.total
                }
                if (response.ret !== '0') {
                    console.log('调用获取所有代理商失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        }
    }
}
</script>

<style lang="stylus" rel="stylesheet/stylus" scoped>
.el-dropdown-link
    color: #409EFF
    cursor: pointer

.order-report
    width: 100%
    background: #fff
    min-height: calc(100vh - 65px)
    position: relative

    .report-table-top-title
        width: 100%
        height: 64px
        line-height: 64px
        color: #000
        font-size: 18px
        background: #f1f0f5

    .report-table-form1
        width: 100%
        min-height: 40px
        padding: 16px 0 0 22px
        box-sizing: border-box
        background: #fff
        overflow: hidden

        .report-table-form1-line
            min-height: 32px
            margin-bottom: 16px

            .report-table-form1-item
                display: inline-block
                vertical-align: top
                height: 32px
                margin-right: 15px
                line-height: 32px

                &.word
                    margin-right: 0

                &.samll
                    font-size: 15px
                    text-align: left

                &.big
                    margin-right: 100px

    .report-table-block
        width: 100%
        padding-top: 22px
        height: 50px
        background: #fff
        box-sizing: border-box

        .report-table-block-in
            float: right
            padding-right: 17px

    .page-padding-gray-small
        width: 100%
        height: 22px
        background: #f1f0f5

    .page-padding
        width: 100%
        height: 20px
        background: #fff

    .report-table-total
        width: 100%
        font-size: 16px
        color: #409EFF
        padding: 22px
        margin-top: 22px
        box-sizing: border-box
        background: #fff

    .page-all-loading
        position: fixed
        top: 55%
        left: 40%
        width: 200px

.title
    display: inline-block
    min-width: 120px
    text-align: right
    font-weight: bold
    line-height: 35px

.value
    display: inline-block
    line-height: 35px
    min-width: 150px

.items
    width: 200px

.item
    margin-bottom: 0px
</style>

